<template>
    <div>
        <button @click="setItem">设值</button>
        <hr>
        <button @click="getItem">取值</button>
    </div>
</template>

<script>
export default {
    data(){
        return {

        }
    },
    methods: {
        setItem(){
            localStorage.params = JSON.stringify({
                name: '张三',
                sex: '男'
            })
        },
        getItem(){
            console.log(localStorage.params)
            console.log(JSON.parse(localStorage.getItem('params')))
        }
    }
}
</script>
